package com.kaishengit.web;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.kaishengit.entity.Document;

import com.kaishengit.service.DocumentService;
import com.kaishengit.util.web.ServletUtil;

public class DocumentEdit extends HttpServlet {
	
	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		
		String id = request.getParameter("id");
		
		Document dt = new DocumentService().findById(id);
		request.setAttribute("dt",dt);
		ServletUtil.forword(request, response, "document/document_edit");
		
	}
		public void doPost(HttpServletRequest request, HttpServletResponse response)
				throws ServletException, IOException {
	
			String id = request.getParameter("id");
			String title = request.getParameter("title");
			String content = request.getParameter("content");
			
			new DocumentService().edit(id,title,content);
			ServletUtil.redirect(response, "document.jspx");
			
			
			
			
			
			
			
			
			
			
			
			

	}

}	
